public class TestThrows {
    public static void computer() throws ArithmeticException {
        int x = (int) (1 + (Math.random() * 2));
        int y = (int) (Math.random() * 2);
        int result = x / y;
        System.out.println("the result is:" + result);
    }

    public static void exp(ArithmeticException e) {
        System.out.println("ArithmeticException类的对象出现");
        e.printStackTrace();
    }

    public static void main(String[] args) {
        try {
            computer();
        } catch (ArithmeticException e) {
            exp(e);
        }
    }
}